# -*- coding: utf-8 -*-
"""
Created on Fri Jun 12 12:41:10 2020

@author: Farman
"""


import joblib


class LandsatFilesMan:
    def __init__(self, joblib_dump_file):
        try:
            self.dict = joblib.load(joblib_dump_file)
        except:
            self.dict = {}
            print('')
            print('Fatal Error:')
            print('----------------------------------------------------------')
            print('    Fail to load file "%s" while initialize LandsatFilesMan.'%joblib_dump_file)
            print("")
            
        return
    
    
    def get_files_of_path_row(self, path, row):
        dict_row_year = self.dict.get(path)
        
        if dict_row_year == None:
            return None
        
        dict_year = dict_row_year.get(row)
        
        if dict_year == None:
            return None
        
        
        fs = list(dict_year.values())
        
        if fs == None:
            return None
        
        s = []
        
        for f in fs:
            s += f
        
        return s
        


'''        
job_dump_file = 'LandsatFileDictInPathRowYear.joblib'

fm = LandsatFilesMan(job_dump_file)
fs = fm.get_files_of_path_row(157,14)

for f in fs:
    print(f)
'''